package com.niiwoo.civet.trade.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Optional;

/**
 * @Author: wuke
 * @Description: 法大大模板相关枚举
 * @Date: Created in 10:56 2017/11/18
 */
public class FadadaContractEnum {

    /**
     * 模板类型枚举：1、极速借借款,2、代扣,3、团贷网发标,4、反担保,5、仲裁,6、送达回证 7.考拉法大大债仅转让合同,8.借款授权委托书,9.考拉理财授权开户委托书
     * 10.委托授权协议,11.风险提示书
     * 12, "团贷授权开户委托书" 13, "借新还旧委托授权书"(老系统后期新增)
     */
    @AllArgsConstructor
    @Getter
    public enum ContractTypeEnum {
        FAST_LOAN((byte)1,"极速借借款"),
        WITHHOLD((byte)2,"代扣"),
        TUANDAI((byte)3,"团贷网发标"),
        ANTI_GUARANTEE((byte)4,"反担保"),
        ARBITRATION((byte)5,"仲裁"),
        RETURN_CERTIFICATE((byte)6,"送达回证"),
        KAOLA_TRANSFER_CONTRACT((byte)7,"考拉法大大债仅转让合同"),
        LOAN_AUTH_PROXY((byte)8,"借款授权委托书"),
        LOAN_ACCOUNT_PROXY((byte)9,"考拉理财授权开户委托书"),
    	CONSIGNOR_AUTHORIZE_PROTOCOL((byte)10,"委托授权协议"),
    	RISK_PROMPT((byte)11,"风险提示书"),
    	TD_AUTH((byte)12, "团贷授权开户委托书"),
    	BORROWNEW_AUTH((byte)13, "借新还旧委托授权书"),
        KAOLA_WITHHOLD((byte)14,"考拉理财还款代扣合同"),

        ORG_COMPANY_FAST_LOAN((byte)15,"机构企业极速借居间借款合同-鸿特"),
        COMPANY_WITHHOLD((byte)16,"企业还款服务委托书"),
        ORG_PERSONAL_FAST_LOAN((byte)17,"机构个人极速借居间借款合同-鸿特"),
        TO8TO_FAST_LOAN((byte)18,"土巴兔极速借居间借款合同");

        private Byte type;
        private String desc;

        public static ContractTypeEnum getByType(byte type) {
            Optional<ContractTypeEnum> contractTypeEnum =
                    Arrays.stream(values()).filter(value -> value.getType() == type).findFirst();
            return contractTypeEnum.isPresent() ? contractTypeEnum.get() : null;
        }
    }

    /**
     * 交易类型枚举：（1：借款， 2：担保， 3：投资，4：批量投资，5：自动投资，6：债权转让）
     */
    @AllArgsConstructor
    @Getter
    public enum TradeTypeEnum {
        LOAN((byte)1,"借款"),
        GUARANTEE((byte)2,"担保"),
        INVEST((byte)3,"手动投资"),
        BATCH_INVEST((byte)4,"批量投资"),
        AUTO_INVEST((byte)5,"自动投资"),
        CREDITOR_TRANSFER((byte)6,"债权转让");

        private Byte type;
        private String desc;

        public static TradeTypeEnum getByType(byte type) {
            Optional<TradeTypeEnum> tradeTypeEnum =
                    Arrays.stream(values()).filter(value -> value.getType() == type).findFirst();
            return tradeTypeEnum.isPresent() ? tradeTypeEnum.get() : null;
        }
    }

    /**
     * 状态枚举 0未签，1已签合同
     */
    @AllArgsConstructor
    @Getter
    public enum StatusEnum {
        NO((byte)0,"未签"),
        YES((byte)1,"已签合同");

        private Byte status;
        private String desc;

        public static StatusEnum getByStatus(byte status) {
            Optional<StatusEnum> statusEnum =
                    Arrays.stream(values()).filter(value -> value.getStatus() == status).findFirst();
            return statusEnum.isPresent() ? statusEnum.get() : null;
        }
    }

    /**
     * 状态枚举 0手动，1自动
     */
    @AllArgsConstructor
    @Getter
    public enum IsAutoEnum {
        HAND((byte)0,"手动"),
        AUTO((byte)1,"自动");

        private Byte type;
        private String desc;

        public static IsAutoEnum getByStatus(byte type) {
            Optional<IsAutoEnum> isAutoEnum =
                    Arrays.stream(values()).filter(value -> value.getType() == type).findFirst();
            return isAutoEnum.isPresent() ? isAutoEnum.get() : null;
        }
    }
}
